package com.pinyougou.manager.controller;


import com.github.pagehelper.PageInfo;
import com.pinyougou.Result;
import com.pinyougou.pojo.TbSeller;
import com.pinyougou.pojo.TbSpecification;
import com.pinyougou.pojo.TbTypeTemplate;
import com.pinyougou.sellergoods.service.SellerService;
import com.pinyougou.sellergoods.service.TypeTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/seller")
public class SellerController {
    @Autowired
    private SellerService sellerService;


    @RequestMapping("/update")
    public Result updateStatus(String sId,String status){
        try {
            sellerService.updateStatus(sId,status);
            return new Result(true,"成功");
        }catch (Exception e){

            return new Result(false,"失败");
        }


    }

    @RequestMapping("/{id}")
    public TbSeller findById(@PathVariable(value = "id")String id){
        TbSeller tbSeller =  sellerService.getOneById(id);
        return tbSeller;

    }

    @RequestMapping("/list")
    public PageInfo<TbSeller> findAll(@RequestBody TbSeller seller,
                                      @RequestParam(value = "page",required = true,defaultValue = "1")Integer page,
                                      @RequestParam(value = "size",required = true,defaultValue = "5")Integer size){
        PageInfo<TbSeller> serviceAll = sellerService.findAll(seller,page,size);
        return serviceAll;
    }
}
